package com.beautify.qrcode.utils;

import com.beautify.qrcode.constants.ErrorCorrectEnum;
import com.beautify.qrcode.constants.QrCodeConstant;
import com.swetake.util.Qrcode;

/**
 * 二维码数组生成工具类
 *
 * @author keia
 * @since 2022/1/15 21:15
 */
public class QrCodeUtils {
    /**
     * 获取二维码数组
     * @param txt
     * @param errorCorrect
     * @return
     */
    public static boolean[][] getQrCode(String txt, ErrorCorrectEnum errorCorrect){
        Qrcode qrcode = new Qrcode();
        qrcode.setQrcodeErrorCorrect(errorCorrect.getType());
        qrcode.setQrcodeEncodeMode(QrCodeConstant.QRCODE_ENCODE_MODE);
        qrcode.setQrcodeVersion(QrCodeConstant.QRCODE_VERSION);
        byte[] d = txt.getBytes();
        boolean[][] s = qrcode.calQrcode(d);
        return s;
    }
}
